import datetime
import re
import time

def gettimelist(starttime="",endtime=""):
    retime = starttime
    if starttime:
        res= re.findall(r"[\d]*",starttime)
        while '' in res:
            res.remove('')
        res=[int(i) for i in res]
        starttime=tuple(res)
    else:
        starttime = time.localtime(time.time())[0:3]
    if endtime:
        res = re.findall(r"[\d]*",endtime)
        while '' in res:
            res.remove('')
        res = [int(i) for i in res]
        endtime=tuple(res)
    else:
        if retime:
            endtime = retime
            res = re.findall(r"[\d]*", endtime)
            while '' in res:
                res.remove('')
            res = [int(i) for i in res]
            endtime = tuple(res)
        else:
            endtime = time.localtime(time.time())[0:3]
    starttime = datetime.date(*starttime)
    endtime = datetime.date(*endtime)
    if endtime<starttime:
        starttime=endtime
    daylist=[datetime.datetime.fromordinal(day) for day in range(starttime.toordinal(),endtime.toordinal()+1)]
    daylist=[str(day.year)+"-"+str(day.month)+"-"+str(day.day) for day in daylist]
    return daylist


